# include "graph.h"
# include <bits/stdc++.h>

namespace MySolve{
# define fi first
# define se second

const int N=205,INF=0x3f3f3f3f;

int n;
std::vector <std::pair <int,int> > G[N];

int col[N];
int lim;
int e_fa[N];
int deg[N];

std::vector <int> typ[N];
std::vector <int> tid[N];

void dfs(int x,int fa){ // this means : new in x
	col[x]=Color(),e_fa[x]=LastRoad(),deg[x]=NumberOfRoads();
	G[x].emplace_back(fa,e_fa[x]);
	if(!typ[x].size()) tid[x]=typ[x]=std::vector <int> (deg[x]+1,0);
	for(int i=1;i<=deg[x];++i){
		if(i==e_fa[x]) continue;
		Move(i,2); int nc=Color();
		if(nc!=1){
			if(nc==2) Move(LastRoad(),nc),typ[x][i]=1;
			else Move(LastRoad(),nc),typ[x][i]=2;
		}else ++n,tid[x][i]=n,G[x].emplace_back(x,i),dfs(n,x);
	}
	if(~e_fa[x]){
		tid[x][e_fa[x]]=fa;
		Move(e_fa[x],3);
	}
	return;
}

void redfs(int x,int base){
	int c=(x/base)%3+1;
	for(int i=1;i<=deg[x];++i){
		if(i==e_fa[x]) continue;
		if(!typ[x][i]) Move(i,c),redfs(tid[x][i],base);
		else if(typ[x][i]==1){
			Move(i,c); tid[x][i]+=base*(Color()-1); Move(LastRoad(),Color());
		}
	}
	if(~e_fa[x]) Move(e_fa[x],c);
	return;
}

int cnt[N];
int dis[N][N];

inline void bfs(int x,int *d){
	for(int i=1;i<=n;++i) d[i]=INF;
	std::queue <int> q; q.push(x),d[x]=0;
	while(!q.empty()){
		int i=q.front(); q.pop();
		for(auto j:tid[i]) if(j&&d[j]==INF) d[j]=d[i]+1,q.push(j);
	}
	for(int i=1;i<=n;++i) ++cnt[d[i]];
	return;
} 

inline void Inspect(int R){
	lim=R;	
	n=1; dfs(1,0);
	for(int b=1;b<=n;b*=3) redfs(1,b);	
	for(int i=1;i<=n;++i) for(auto j:tid[i]) if(j) tid[j].push_back(i);
	for(int i=1;i<=n;++i) bfs(i,dis[i]);
	for(int i=1;i<=R;++i) Answer(i,cnt[i]/2);

	return;
}

# undef fi
# undef se

}

inline void Inspect(int R){
	return MySolve::Inspect(R);
}
